package states;

import levels.LevelTest;

import objects.Camera;

import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.SpriteSheet;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;


import entities.Player;
import divers.StaticVariables;


public class InGame extends BasicGameState{

	public final int ID = 1;
	
	private LevelTest lvl1;
	private Player joueur;
	private Camera camera;
	@Override
	public void init(GameContainer gc, StateBasedGame arg1)
			throws SlickException {
		
		camera = new Camera();
		joueur = new Player();
		joueur.init(gc, arg1);
		StaticVariables.sheet = new SpriteSheet("data\\tileset.png", 10, 10);
		lvl1 = new LevelTest();
		lvl1.init(gc);
	}

	@Override
	public void render(GameContainer gc, StateBasedGame arg1, Graphics g)
			throws SlickException {
		
		g.translate(-(int)camera.getPosition().x, -(int)camera.getPosition().y);
		g.setBackground(Color.cyan);
		lvl1.render(gc, g);
		joueur.render(gc, arg1, g);
	}

	@Override
	public void update(GameContainer gc, StateBasedGame arg1, int arg2)
			throws SlickException {
		
		joueur.update(gc, arg1, arg2);
		camera.update(gc);
	}

	@Override
	public int getID() {
		
		return ID;
	}

}


